home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / gs261src.zip / gxfont.h < prev    next >
C/C++ Source or Header  |  1993-05-27  |  6KB  |  186 lines

  1. /* Copyright (C) 1989, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gxfont.h */
  20. /* Internal font definition for Ghostscript library */
  21. /* Requires gsccode.h, gsmatrix.h, gxdevice.h */
  22. #include "gsfont.h"
  23. #include "gsuid.h"
  24.  
  25. /* A font object as seen by clients. */
  26. /* See the PostScript Language Reference Manual for details. */
  27.  
  28. #ifndef gs_show_enum_s_DEFINED
  29. struct gs_show_enum_s;
  30. #endif
  31.  
  32. /* A client-supplied BuildChar/BuildGlyph procedure. */
  33. /* The gs_char may be gs_no_char (for BuildGlyph), or the gs_glyph */
  34. /* may be gs_no_glyph (for BuildChar), but not both. */
  35. #define gs_proc_build_char(proc)\
  36.   int proc(P5(struct gs_show_enum_s *, struct gs_state_s *,\
  37.     gs_font *, gs_char, gs_glyph))
  38.  
  39. gs_proc_build_char(gs_no_build_char_proc);
  40.  
  41. /* A client-supplied character encoding procedure. */
  42. #define gs_proc_encode_char(proc)\
  43.   gs_glyph proc(P3(struct gs_show_enum_s *, gs_font *, gs_char *))
  44.  
  45. gs_proc_encode_char(gs_no_encode_char_proc);
  46.  
  47. /* Define the known font types. */
  48. /* These numbers must be the same as the values of FontType */
  49. /* in font dictionaries. */
  50. typedef enum {
  51.     ft_composite = 0,
  52.     ft_encrypted = 1,
  53.     ft_user_defined = 3
  54. } font_type;
  55.  
  56. /* Define the bitmap font behaviors. */
  57. /* These numbers must be the same as the values of the ExactSize, */
  58. /* InBetweenSize, and TransformedChar entries in font dictionaries. */
  59. typedef enum {
  60.     fbit_use_outlines = 0,
  61.     fbit_use_bitmaps = 1,
  62.     fbit_transform_bitmaps = 2
  63. } fbit_type;
  64.  
  65. /* Define the composite font mapping types. */
  66. /* These numbers must be the same as the values of FMapType */
  67. /* in type 0 font dictionaries. */
  68. typedef enum {
  69.     fmap_8_8 = 2,
  70.     fmap_escape = 3,
  71.     fmap_1_7 = 4,
  72.     fmap_9_7 = 5,
  73.     fmap_SubsVector = 6,
  74.     fmap_double_escape = 7,
  75.     fmap_shift = 8
  76. } fmap_type;
  77. #define fmap_type_min 2
  78. #define fmap_type_max 8
  79. #define fmap_type_is_modal(fmt)\
  80.   ((fmt) == fmap_escape || (fmt) == fmap_double_escape || (fmt) == fmap_shift)
  81.  
  82. /* This is the type-specific information for a type 0 (composite) gs_font. */
  83. typedef struct gs_type0_data_s gs_type0_data;
  84. struct gs_type0_data_s {
  85.     fmap_type FMapType;
  86.     byte EscChar, ShiftIn, ShiftOut;
  87.     byte *SubsVector;
  88.       uint subs_size;        /* bytes per entry */
  89.       uint subs_width;        /* # of entries */
  90.     uint *Encoding;
  91.       uint encoding_size;
  92.     gs_font **FDepVector;
  93.       uint fdep_size;
  94. };
  95.  
  96. /* This is the type-specific information for a type 1 (encrypted) gs_font. */
  97. /* The zone_table values should be ints, according to the Adobe */
  98. /* specification, but some fonts have arbitrary floats here. */
  99. #define zone_table(size)\
  100.     struct {\
  101.         int count;\
  102.         float values[(size)*2];\
  103.     }
  104. #define stem_table(size)\
  105.     struct {\
  106.         int count;\
  107.         float values[size];\
  108.     }
  109. typedef struct gs_type1_data_s gs_type1_data;
  110. struct gs_type1_data_s {
  111.     int PaintType;
  112.     int (*subr_proc)(P3(gs_type1_data *pdata,
  113.                 int index, const byte **pcharstring));
  114.     int (*pop_proc)(P2(gs_type1_data *, fixed *));
  115.     char *proc_data;        /* data for subr_proc */
  116.     int lenIV;
  117.     /* For a description of the following hint information, */
  118.     /* see chapter 5 of the "Adobe Type 1 Font Format" book. */
  119.     int BlueFuzz;
  120.     float BlueScale;
  121.     float BlueShift;
  122. #define max_BlueValues 7
  123.     zone_table(max_BlueValues) BlueValues;
  124.     float ExpansionFactor;
  125.     int ForceBold;
  126. #define max_FamilyBlues 7
  127.     zone_table(max_FamilyBlues) FamilyBlues;
  128. #define max_FamilyOtherBlues 5
  129.     zone_table(max_FamilyOtherBlues) FamilyOtherBlues;
  130.     int LanguageGroup;
  131. #define max_OtherBlues 5
  132.     zone_table(max_OtherBlues) OtherBlues;
  133.     int RndStemUp;
  134.     stem_table(1) StdHW;
  135.     stem_table(1) StdVW;
  136. #define max_StemSnap 12
  137.     stem_table(max_StemSnap) StemSnapH;
  138.     stem_table(max_StemSnap) StemSnapV;
  139. };
  140. #define gs_type1_data_s_DEFINED
  141.  
  142. /* Even though it costs a little extra space, it's more convenient to */
  143. /* include all the necessary information for >>all<< known font types */
  144. /* (user-defined, encrypted, and composite) in the font structure. */
  145. /* The font names are only needed for xfont lookup. */
  146. typedef struct gs_font_name_s {
  147. #define gs_font_name_max 47        /* must be >= 40 */
  148.     /* The +1 is so we can null-terminate for debugging printout. */
  149.     byte chars[gs_font_name_max+1];
  150.       uint size;
  151. } gs_font_name;
  152. struct gs_font_s {
  153.     gs_font *next, *prev;        /* chain for original font list or */
  154.                     /* scaled font cache */
  155.     gs_font_dir *dir;        /* directory where registered */
  156.     gs_font *base;            /* original (unscaled) base font */
  157.     char *client_data;        /* additional client data */
  158.     gs_matrix FontMatrix;
  159.     font_type FontType;
  160.     int BitmapWidths;        /* boolean */
  161.     fbit_type ExactSize, InBetweenSize, TransformedChar;
  162.     int WMode;            /* 0 or 1 */
  163.     gs_proc_build_char((*build_char_proc));    /* BuildChar/BuildGlyph */
  164.     gs_proc_encode_char((*encode_char_proc));
  165.     gs_proc_glyph_name((*glyph_name_proc));
  166.     union _d {
  167.         /* Composite (type 0) fonts */
  168.         gs_type0_data type0_data;
  169.         /* Base (non-type 0) fonts */
  170.         struct _b {
  171.             gs_rect FontBBox;
  172.             gs_uid UID;
  173.             int encoding_index;    /* 0=Std, 1=ISOLatin1, */
  174.                         /* 2=Symbol, 3=Dingbats, */
  175.                         /* -1=other */
  176.             int nearest_encoding_index;    /* (may be >= 0 */
  177.                     /* even if encoding_index = -1) */
  178.             /* Type 1 data */
  179.             gs_type1_data type1_data;
  180.         } base;
  181.     } data;
  182.     /* We store both the FontDirectory key (key_name) and, */
  183.     /* if present, the FontName (font_name). */
  184.     gs_font_name key_name, font_name;
  185. };
  186.